package com.TwinBlade.PicturePassword;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
import android.os.Environment;
import android.os.Handler;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.view.Display;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import java.io.File;
import java.io.FileInputStream;
import java.util.Calendar;

public class bl
{
  public static boolean a = false;
  public static boolean b = false;
  private static boolean k = false;
  private Runnable A;
  private boolean B = false;
  private final GestureDetector C = new GestureDetector(this.c, new bm(this));
  private Context c;
  private SharedPreferences d;
  private WindowManager e;
  private AudioManager f;
  private int g;
  private boolean h;
  private boolean i;
  private boolean j;
  private aj l;
  private al m;
  private TextView n;
  private LinearLayout o;
  private TextView p;
  private ak q;
  private LinearLayout r;
  private TextView s;
  private LinearLayout t;
  private LinearLayout u;
  private LinearLayout v;
  private TextView w;
  private Bitmap x;
  private Handler y;
  private Runnable z;

  private bl(Context paramContext)
  {
    this.c = paramContext;
    this.d = PreferenceManager.getDefaultSharedPreferences(this.c);
    this.e = ((WindowManager)Utilities.c.getSystemService("window"));
    this.f = ((AudioManager)this.c.getSystemService("audio"));
    this.y = new Handler();
    this.z = new bx(this);
    this.A = new ci(this);
  }

  private int a(BitmapFactory.Options paramOptions, int paramInt1, int paramInt2)
  {
    int i1 = paramOptions.outHeight;
    int i2 = paramOptions.outWidth;
    int i3 = 1;
    if ((i1 > paramInt2) || (i2 > paramInt1))
    {
      if (i1 > i2)
        i3 = Math.round(i2 / paramInt1);
    }
    else
      return i3;
    return Math.round(i1 / paramInt2);
  }

  public static bl a(Context paramContext, boolean paramBoolean)
  {
    if ((paramBoolean) && (Utilities.d == null))
      Utilities.d = new bl(paramContext);
    return Utilities.d;
  }

  private void a(int paramInt)
  {
    long l1 = SystemClock.uptimeMillis();
    Intent localIntent = new Intent("android.intent.action.MEDIA_BUTTON", null);
    KeyEvent localKeyEvent = new KeyEvent(l1, l1, 0, paramInt, 0);
    localIntent.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent);
    this.c.sendOrderedBroadcast(localIntent, null);
    localIntent.putExtra("android.intent.extra.KEY_EVENT", KeyEvent.changeAction(localKeyEvent, 1));
    this.c.sendOrderedBroadcast(localIntent, null);
  }

  private void a(View paramView)
  {
    if (this.l != null)
      return;
    this.l = new aj(this.c, 16973840);
    this.l.setOnDismissListener(new cm(this));
    if (!this.i)
    {
      this.l.getWindow().setType(2010);
      this.l.getWindow().addFlags(65792);
      if (this.h)
        break label147;
      this.l.getWindow().addFlags(2048);
    }
    while (true)
    {
      this.l.setCancelable(false);
      this.l.setOnKeyListener(new cn(this));
      this.l.setContentView(paramView);
      this.l.show();
      return;
      this.l.getWindow().setType(2003);
      break;
      label147: this.l.getWindow().addFlags(1024);
    }
  }

  private void a(boolean paramBoolean, ImageView paramImageView)
  {
    int i1 = 2130837506;
    int i2 = 2130837505;
    if (this.f.isMusicActive())
    {
      Resources localResources2 = this.c.getResources();
      if (paramBoolean);
      while (true)
      {
        paramImageView.setImageDrawable(localResources2.getDrawable(i2));
        return;
        i2 = i1;
      }
    }
    Resources localResources1 = this.c.getResources();
    if (paramBoolean);
    while (true)
    {
      paramImageView.setImageDrawable(localResources1.getDrawable(i1));
      return;
      i1 = i2;
    }
  }

  private void a(boolean paramBoolean, File paramFile)
  {
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inJustDecodeBounds = true;
    if (paramBoolean);
    try
    {
      FileInputStream localFileInputStream2 = this.c.openFileInput("PhotoData.jpg");
      BitmapFactory.decodeStream(localFileInputStream2, null, localOptions);
      localFileInputStream2.close();
      while (true)
      {
        label42: Display localDisplay = this.e.getDefaultDisplay();
        localOptions.inSampleSize = a(localOptions, localDisplay.getWidth(), localDisplay.getHeight());
        localOptions.inJustDecodeBounds = false;
        if (paramBoolean);
        try
        {
          FileInputStream localFileInputStream1 = this.c.openFileInput("PhotoData.jpg");
          this.x = BitmapFactory.decodeStream(localFileInputStream1, null, localOptions);
          localFileInputStream1.close();
          return;
          BitmapFactory.decodeFile(paramFile.getPath(), localOptions);
          continue;
          this.x = BitmapFactory.decodeFile(paramFile.getPath(), localOptions);
          return;
        }
        catch (Exception localException1)
        {
        }
      }
    }
    catch (Exception localException2)
    {
      break label42;
    }
  }

  public static boolean a()
  {
    AudioManager localAudioManager = (AudioManager)Utilities.c.getSystemService("audio");
    return (localAudioManager.getMode() == 2) || (localAudioManager.getMode() == 1) || (k) || (a) || (b);
  }

  public static boolean b()
  {
    return Utilities.d != null;
  }

  public static void c(boolean paramBoolean)
  {
    k = paramBoolean;
  }

  private void g()
  {
    if (Environment.getExternalStorageState().equals("mounted"))
    {
      File localFile1 = this.c.getExternalFilesDir(null);
      if (localFile1 == null)
        localFile1 = new File(Environment.getExternalStorageDirectory() + "/PPAData");
      File localFile2 = new File(localFile1, "PhotoData.jpg");
      if (localFile2.exists())
      {
        a(false, localFile2);
        if (this.x != null)
          return;
      }
    }
    a(true, null);
  }

  private void g(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      if (this.o != null)
        return;
      WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
      localLayoutParams.type = 2003;
      localLayoutParams.flags = 262184;
      localLayoutParams.width = 1;
      localLayoutParams.height = 1;
      localLayoutParams.gravity = 83;
      localLayoutParams.format = -2;
      this.o = new LinearLayout(this.c);
      this.e.addView(this.o, localLayoutParams);
      this.o.setOnTouchListener(new ck(this));
      return;
    }
    try
    {
      this.e.removeView(this.o);
      label114: this.o = null;
      return;
    }
    catch (Exception localException)
    {
      break label114;
    }
  }

  private TextView h()
  {
    this.w = new TextView(this.c);
    this.w.setBackgroundColor(Color.argb(115, 0, 0, 0));
    this.w.setLayoutParams(new FrameLayout.LayoutParams(-2, -2, 1));
    this.w.setGravity(49);
    this.w.setText(this.c.getString(2131296424));
    this.w.setOnClickListener(new co(this));
    return this.w;
  }

  private void h(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      if (this.n != null)
        return;
      WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
      localLayoutParams.type = 2010;
      localLayoutParams.flags = 327976;
      localLayoutParams.width = -1;
      localLayoutParams.height = Utilities.b;
      localLayoutParams.gravity = 51;
      localLayoutParams.format = -2;
      this.n = new TextView(this.c);
      this.n.setGravity(17);
      this.n.setBackgroundColor(Color.argb(200, 57, 146, 181));
      this.n.setText(this.c.getString(2131296468));
      this.e.addView(this.n, localLayoutParams);
      this.n.setVisibility(8);
      this.n.setOnTouchListener(new cl(this));
      return;
    }
    try
    {
      this.e.removeView(this.n);
      label172: this.n = null;
      return;
    }
    catch (Exception localException)
    {
      break label172;
    }
  }

  private LinearLayout i()
  {
    this.v = new LinearLayout(this.c);
    this.v.setBackgroundColor(Color.argb(120, 0, 0, 0));
    this.v.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
    this.v.setGravity(17);
    this.v.setOrientation(1);
    this.v.setOnClickListener(new cp(this));
    TextView localTextView1 = new TextView(this.c);
    localTextView1.setText(this.c.getString(2131296412));
    localTextView1.setTextSize(20.0F);
    localTextView1.setGravity(17);
    this.v.addView(localTextView1);
    TextView localTextView2 = new TextView(this.c);
    localTextView2.setText(this.c.getString(2131296413));
    localTextView2.setTextSize(20.0F);
    localTextView2.setGravity(17);
    this.v.addView(localTextView2);
    return this.v;
  }

  private void i(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      this.m = new al(this.c);
      this.q = ak.a(this.c, true);
      BitmapDrawable localBitmapDrawable = new BitmapDrawable(this.c.getResources(), this.x);
      this.q.setBackgroundDrawable(localBitmapDrawable);
      this.m.addView(this.q);
      if ((this.d.getBoolean("InfoPanel", false)) && (bd.a(this.c)))
        this.m.addView(j());
      this.m.addView(k());
      if (this.d.getBoolean("SpecialGestureHint", true))
        this.m.addView(i());
      if ((!this.d.getString("OwnersInfo", "").equals("")) && (bd.a(this.c)))
        this.m.addView(h());
      a(this.m);
      return;
    }
    try
    {
      this.l.dismiss();
      label205: this.l = null;
      this.m = null;
      return;
    }
    catch (Exception localException)
    {
      break label205;
    }
  }

  private LinearLayout j()
  {
    this.r = new LinearLayout(this.c);
    this.r.setOrientation(1);
    int i1 = this.d.getInt("TimeFontSize", 75);
    int i2 = Integer.parseInt(this.d.getString("InfoPanelPosX", "0"));
    int i3 = Integer.parseInt(this.d.getString("InfoPanelPosY", "0"));
    int i4;
    switch (i2)
    {
    default:
      i4 = 0;
      switch (i3)
      {
      default:
        label136: this.r.setLayoutParams(new FrameLayout.LayoutParams(-2, -2, i4));
        this.p = new TextView(this.c);
        e();
        this.p.setTextSize(i1);
        this.p.setTextColor(Color.argb(Color.alpha(this.g), Color.red(this.g), Color.green(this.g), Color.blue(this.g)));
        this.p.setFocusable(false);
        this.r.addView(this.p);
        if ((!this.d.getBoolean("InfoDateBattery", false)) || (!bd.a(this.c)));
        break;
      case 0:
      case 1:
      case 2:
      }
      break;
    case 0:
    case 1:
    case 2:
    }
    for (int i5 = 1; ; i5 = 0)
    {
      if (i5 != 0)
      {
        int i6 = this.d.getInt("ExtraFontSize", 45);
        this.s = new TextView(this.c);
        f();
        this.s.setTextSize(i6);
        this.s.setTextColor(Color.argb(Color.alpha(this.g), Color.red(this.g), Color.green(this.g), Color.blue(this.g)));
        this.s.setFocusable(false);
        this.r.addView(this.s);
      }
      if (this.d.getBoolean("PPAFont", false))
      {
        Typeface localTypeface = Typeface.createFromAsset(this.c.getAssets(), "fonts/Roboto-Regular.ttf");
        if (this.p != null)
          this.p.setTypeface(localTypeface);
        if (this.s != null)
          this.s.setTypeface(localTypeface);
      }
      return this.r;
      i4 = 48;
      break;
      i4 = 16;
      break;
      i4 = 80;
      break;
      i4 |= 3;
      break label136;
      i4 |= 1;
      break label136;
      i4 |= 5;
      break label136;
    }
  }

  private void j(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      Intent localIntent1 = new Intent();
      localIntent1.setClassName("com.TwinBlade.PicturePassword.RootHelper", "com.TwinBlade.PicturePassword.RootHelper.RHService");
      localIntent1.putExtra("DisableStat", true);
      this.c.startService(localIntent1);
      return;
    }
    this.c.sendBroadcast(new Intent("com.TwinBlade.PicturePassword.RootHelper.INTENT"));
    Intent localIntent2 = new Intent();
    localIntent2.setClassName("com.TwinBlade.PicturePassword.RootHelper", "com.TwinBlade.PicturePassword.RootHelper.RHService");
    this.c.stopService(localIntent2);
  }

  private LinearLayout k()
  {
    this.t = new LinearLayout(this.c);
    this.t.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
    this.t.setOrientation(1);
    this.t.setGravity(81);
    this.t.setVisibility(8);
    this.t.setOnClickListener(new bn(this));
    if (this.d.getBoolean("EmergencyDialer", true))
    {
      Button localButton1 = new Button(this.c);
      localButton1.setText(this.c.getString(2131296425));
      this.t.addView(localButton1);
      localButton1.setOnClickListener(new bo(this));
    }
    Button localButton2 = new Button(this.c);
    localButton2.setText(this.c.getString(2131296426));
    this.t.addView(localButton2);
    localButton2.setOnClickListener(new bp(this));
    Button localButton3 = new Button(this.c);
    localButton3.setText(this.c.getString(2131296427));
    this.t.addView(localButton3);
    localButton3.setOnClickListener(new bq(this));
    if ((this.d.getBoolean("MusicControl", true)) && (bd.a(this.c)))
    {
      this.u = new LinearLayout(this.c);
      this.u.setGravity(17);
      ImageView localImageView1 = new ImageView(this.c);
      ImageView localImageView2 = new ImageView(this.c);
      ImageView localImageView3 = new ImageView(this.c);
      a(true, localImageView1);
      localImageView2.setImageDrawable(this.c.getResources().getDrawable(2130837504));
      localImageView3.setImageDrawable(this.c.getResources().getDrawable(2130837507));
      localImageView1.setOnClickListener(new br(this, localImageView1));
      localImageView2.setOnClickListener(new bs(this));
      localImageView3.setOnClickListener(new bt(this));
      this.u.addView(localImageView3);
      this.u.addView(localImageView1);
      this.u.addView(localImageView2);
      this.t.addView(this.u);
    }
    return this.t;
  }

  public void a(boolean paramBoolean)
  {
    if (paramBoolean)
      if (this.r != null)
        this.r.setVisibility(8);
    try
    {
      this.c.unregisterReceiver(AService.a);
      return;
      if (this.r != null)
        this.r.setVisibility(0);
      IntentFilter localIntentFilter = new IntentFilter("android.intent.action.TIME_TICK");
      this.c.registerReceiver(AService.a, localIntentFilter);
      return;
    }
    catch (Exception localException)
    {
    }
  }

  public void b(boolean paramBoolean)
  {
    if (a())
      return;
    this.h = this.d.getBoolean("HideStatusBar", false);
    this.g = this.d.getInt("ThemeColor", Color.argb(200, 57, 146, 181));
    this.i = this.d.getBoolean("DisplayStockLockscreen", false);
    this.j = this.d.getBoolean("NavBarMode", false);
    g();
    if ((!Utilities.a(true, false)) || (this.x == null))
      d();
    while (true)
    {
      h(true);
      g(true);
      if (paramBoolean)
        Utilities.b();
      if (this.j)
        j(true);
      Utilities.a("CREATE LOCK");
      return;
      i(true);
    }
  }

  public void c()
  {
    Utilities.a("UNLOCK DEVICE");
    a = false;
    b = false;
    LockActivity.c();
    this.c.sendBroadcast(new Intent("com.TwinBlade.PicturePassword.EXIT_LOCK"));
    i(false);
    h(false);
    g(false);
    if (this.j)
      j(false);
    try
    {
      this.c.unregisterReceiver(AService.a);
      label71: Utilities.a(this.c);
      if (this.q != null)
      {
        this.q.setBackgroundDrawable(null);
        this.q = null;
      }
      if (this.x != null)
      {
        this.x.recycle();
        this.x = null;
      }
      Utilities.d = null;
      return;
    }
    catch (Exception localException)
    {
      break label71;
    }
  }

  public void d()
  {
    View localView = ((LayoutInflater)this.c.getSystemService("layout_inflater")).inflate(2130903047, null);
    localView.setBackgroundColor(-16777216);
    if (this.l == null)
      a(localView);
    while (true)
    {
      Button localButton1 = (Button)this.l.findViewById(2131230758);
      Button localButton2 = (Button)this.l.findViewById(2131230756);
      Button localButton3 = (Button)this.l.findViewById(2131230742);
      Button localButton4 = (Button)this.l.findViewById(2131230747);
      Button localButton5 = (Button)this.l.findViewById(2131230748);
      Button localButton6 = (Button)this.l.findViewById(2131230749);
      Button localButton7 = (Button)this.l.findViewById(2131230750);
      Button localButton8 = (Button)this.l.findViewById(2131230751);
      Button localButton9 = (Button)this.l.findViewById(2131230752);
      Button localButton10 = (Button)this.l.findViewById(2131230753);
      Button localButton11 = (Button)this.l.findViewById(2131230754);
      Button localButton12 = (Button)this.l.findViewById(2131230755);
      Button localButton13 = (Button)this.l.findViewById(2131230757);
      EditText localEditText = (EditText)this.l.findViewById(2131230746);
      localEditText.setEnabled(false);
      localEditText.setHint(this.c.getString(2131296406));
      StringBuilder localStringBuilder = new StringBuilder();
      bu localbu = new bu(this, localEditText);
      localButton1.setOnClickListener(localbu);
      localButton2.setOnClickListener(new bv(this, localStringBuilder, localEditText));
      localButton2.setOnLongClickListener(new bw(this, localStringBuilder, localEditText));
      localButton3.setOnClickListener(new by(this));
      localButton4.setOnClickListener(new bz(this, localStringBuilder, localEditText));
      localButton5.setOnClickListener(new ca(this, localStringBuilder, localEditText));
      localButton6.setOnClickListener(new cb(this, localStringBuilder, localEditText));
      localButton7.setOnClickListener(new cc(this, localStringBuilder, localEditText));
      localButton8.setOnClickListener(new cd(this, localStringBuilder, localEditText));
      localButton9.setOnClickListener(new ce(this, localStringBuilder, localEditText));
      localButton10.setOnClickListener(new cf(this, localStringBuilder, localEditText));
      localButton11.setOnClickListener(new cg(this, localStringBuilder, localEditText));
      localButton12.setOnClickListener(new ch(this, localStringBuilder, localEditText));
      localButton13.setOnClickListener(new cj(this, localStringBuilder, localEditText));
      return;
      this.l.setContentView(localView);
    }
  }

  public void d(boolean paramBoolean)
  {
    if (this.t != null)
    {
      if (paramBoolean)
      {
        if ((this.u != null) && (!this.f.isMusicActive()))
          this.u.setVisibility(8);
        this.t.setVisibility(0);
      }
    }
    else
      return;
    this.t.setVisibility(8);
  }

  public void e()
  {
    Calendar localCalendar = Calendar.getInstance();
    String str1 = Integer.toString(localCalendar.get(12));
    String str2;
    if (this.d.getBoolean("24HourTime", false))
      str2 = Integer.toString(localCalendar.get(11));
    while (true)
    {
      if (str1.length() == 1)
        str1 = "0" + str1;
      if (this.p != null)
        this.p.setText(str2 + " : " + str1);
      return;
      str2 = Integer.toString(localCalendar.get(10));
      if (str2.equals("0"))
        str2 = "12";
    }
  }

  public void e(boolean paramBoolean)
  {
    if ((!paramBoolean) && ((a()) || (a)))
      return;
    Utilities.a("LOCK RESUMED");
    if (this.l != null)
      this.l.getWindow().clearFlags(16);
    if (this.m != null)
      this.m.setVisibility(0);
    if (this.n != null)
      this.n.setVisibility(8);
    if (this.d.getBoolean("InfoPanel", false))
      a(false);
    LockActivity.a(false);
  }

  public void f()
  {
    Calendar localCalendar = Calendar.getInstance();
    String str = "";
    switch (1 + localCalendar.get(2))
    {
    default:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    }
    while (true)
    {
      int i1 = this.c.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")).getIntExtra("level", -1);
      if (this.s != null)
        this.s.setText(str + " " + Integer.toString(localCalendar.get(5)) + "   " + Integer.toString(i1) + "%");
      return;
      str = "Jan";
      continue;
      str = "Feb";
      continue;
      str = "Mar";
      continue;
      str = "Apr";
      continue;
      str = "May";
      continue;
      str = "Jun";
      continue;
      str = "Jul";
      continue;
      str = "Aug";
      continue;
      str = "Sep";
      continue;
      str = "Oct";
      continue;
      str = "Nov";
      continue;
      str = "Dec";
    }
  }

  public void f(boolean paramBoolean)
  {
    Utilities.a("LOCK PAUSED");
    if (paramBoolean)
    {
      if (!LockActivity.d())
        return;
      LockActivity.a(true);
    }
    if (this.l != null)
      this.l.getWindow().addFlags(16);
    if (this.m != null)
      this.m.setVisibility(8);
    if (this.n != null)
      this.n.setVisibility(0);
    d(false);
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     com.TwinBlade.PicturePassword.bl
 * JD-Core Version:    0.6.2
 */